package library

import static org.junit.Assert.*

import grails.test.mixin.*
import grails.test.mixin.support.*
import org.junit.*

class BookConstraintsUnitTestTests extends GrailsUnitTestCase{
    def book;
    
    void setUp() {
        super.setup()
        mockForConstraintsTest(Book)
        book = new Book(author: "Anonymous",
                title: "Eggs", description: "yummy",
                isbn: "0000000000" , minGrade: 2, maxGrade: 6,
                language: "General Leisure Reading", category: "fiction");
    }
    
    void testFieldsNullable_Pass(){
        assertTrue 'validation shoud have passed ' , book.validate()
    }

    void testFieldsNullable_Fail(){
        book.title = null
        assertFalse 'validation shoud have failed ' , book.validate()
    }
    
    void testISBN_Pass(){
        assertTrue 'validation shoud have passed ' , book.validate()
    }

    void testISBN_Fail(){
        book.isbn = 12345
        assertFalse 'validation shoud have failed ' , book.validate()
    }
    
    
    void tearDown() {
        super.teardown()
    }

    void testSomething() {
        fail "Implement me"
    }
}
